package it.polimi.loganalyzer;

import it.polimi.loganalyzer.LogAnalyzer;
import it.polimi.loganalyzer.loader.apache.ApacheLoader;
import it.polimi.loganalyzer.model.State;

import java.io.File;

public class LogAnalyzerDemo {
	
	public static void main(String[] args) {
		File logFile = new File("res/sognando_admin.log");
		ApacheLoader apacheLoader = new ApacheLoader(logFile);
		LogAnalyzer logAnalyzer;
		logAnalyzer = new LogAnalyzer("res/Log4j.conf");
		logAnalyzer.setStemmer(new Stemmer());

		logAnalyzer.registerStateExpression("/annunci/affitto/\\?", new State("Affitto",0));
		logAnalyzer.registerStateExpression("/annunci/vendita/\\?", new State("Vendita",0));
		logAnalyzer.registerStateExpression("/annunci/affitto/$", new State("Affitto",0));
		logAnalyzer.registerStateExpression("/annunci/vendita/$", new State("Vendita",0));
		logAnalyzer.registerStateExpression("/annunci/affitto/(\\w+)", new State("AnnuncioA",0));
		logAnalyzer.registerStateExpression("/annunci/vendita/(\\w+)", new State("AnnuncioV",0));
		logAnalyzer.registerStateExpression("^/$", new State("Home",0));
		logAnalyzer.registerStateExpression("^http://www.sognandocasa.it/$", new State("Home",0));
		logAnalyzer.registerStateExpression("/agenzia/", new State("Agenzia",0));
		logAnalyzer.registerStateExpression("/news/list/", new State("News",0));
		logAnalyzer.registerStateExpression("/contattaci/info/", new State("Contatti",0));
		
		try {
			logAnalyzer.analyze(apacheLoader);
			System.out.println(logAnalyzer.generateModel());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
